package com.java.parallel.threadBand.minsheng;

import java.util.Scanner;

/**
 * @author guoyu
 * @date 2022/12/3
 * @Version 1.0
 * @Description TODO
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        sc.nextLine();
        String str = sc.nextLine();
//        deal(n, k, str);
        int res = 0;

        for (int i = 0; i < n; i++) {
            for (int j = i + 1; j < n; j++) {
                if (isLegal(str, i, j, k)) {
                    res += n - j;
                    break;
                }
            }
        }
        System.out.println(res);
    }

    private static boolean isLegal(String str, int l, int r, int k) {
        int res = 0;
        for (int i = l; i <= r; i++) {
            for (int j = i + 1; j <= r; j++) {
                if (str.charAt(i) == ')') {
                    continue;
                }
                if (str.charAt(i) == '(' && str.charAt(j) == ')') {
                    res++;
                }
            }
        }
        if (res >= k) {
            return true;
        } else {
            return false;
        }

    }
}
